package com.zhongke.common.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;

/**
 * 展示九宫格图片时，点击空白处的事件触发点击事件
 * Created by Fushize on 2018/4/20.
 */

public class NineImgRecyclerview extends RecyclerView {
    public NineImgRecyclerview(Context context) {
        super(context);
    }

    public NineImgRecyclerview(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public NineImgRecyclerview(Context context, @Nullable AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    public boolean onTouchEvent(MotionEvent e) {
        switch (e.getAction()) {
            case MotionEvent.ACTION_UP:
                if (onTouchUpListener != null) {
                    onTouchUpListener.touchUp();
                }
                break;
        }
        return true;
    }

    public OnTouchUpListener onTouchUpListener;

    public interface OnTouchUpListener {
        void touchUp();
    }

    public void setOnTouchUpListener(OnTouchUpListener onTouchUpListener) {
        this.onTouchUpListener = onTouchUpListener;
    }
}
